import json

import pytest

from zonghe.caw import file_reader, data_base



#   返回test.ini配置文件中的base_url配置
from zonghe.caw.bese_request import BaseRequest


@pytest.fixture(scope="session")
def base_url():
    return file_reader.read_config("base_url")


#   返回BaseRequest的实例
@pytest.fixture(scope="session")
def test_request():
    return BaseRequest()


#   清理数据库
@pytest.fixture(scope="session", autouse=True)
def clean_db():
    db_info = json.loads(file_reader.read_config("db_info"))
    conn = data_base.connect(db_info)
    data_base.execute(conn, "delete from member where MobilePhone like '17395627375'")
    print(data_base.execute(conn, "select * from member where MobilePhone like '17395627375'"))
    data_base.dis_connect(conn)
